Universal Serial Bus (USB) ports have been employed widely to connect peripheral devices to computers. Typical peripheral connections connected through USB are Printers, scanners, zip drives, digital cameras, mice, joysticks, modems, speakers, telephones, video phones and network connections.
Almost all peripheral devices now come in a USB version. The Universal Serial Bus allows for the connection of up to 128 devices to a computer. Upon connection of a new device the operating system auto-detects it and requests driver input. If the device has already been installed, the computer activates it and starts communication with it.
FIG. 1 illustrates a conventional USB 1.1 master-slave system 100 connected to a USB 1.1 slave only device 107. The USB master-slave system 100 includes a USB 1.1 device 101, a USB 1.1 host 102 and a microcontroller 103 that provides control of the device 101 and host 102 as well as USB 1.1 protocol communications capability with USB 1.1 device 107 through USB 1.1 connectors 104 and 106 via USB 1.1 cable 105.
Many USB devices come with their own cable. The cable either has an A connection or the device has a socket that accepts a USB B connector. The USB standard uses A and B connectors to avoid confusion. A connectors are connected to host default functions. B connectors are connected to device default functions.
Using different connectors on the upstream and downstream end avoids any possible confusion and any USB device having either A or B cabling will function properly. The Universal Serial Bus has the following features. The computer acts as the host. Up to 127devices can connect to the host either directly or via a USB hub. Individual USB cables can run as long as 5 meters. Using a hub, devices can be up to 30 meters or about six cable lengths away from the host. A USB 1.1 bus has a maximum data rate of 12 megabits per second; A USB 2.0 bus has a maximum data rate of 480 megabits per second. A USB cable has two wires for power (+5 volts and ground) and a twisted pair of wires carrying data in differential form. The computer can supply up to 500 milliamps of power at 5 volts on the power wires. Low-power devices, such as a mouse, can draw their power directly from the bus. High-power devices such as printers must have their own power supplies and draw minimal power from the bus. Hubs can have their own power supplies to provide power to devices connected to the hub. USB devices are hot-swappable because the user can plug them into the bus and unplug them any time. Many USB devices can be put to sleep by the host computer when the computer enters a power-saving mode.
Slave devices connected to a USB port rely on the USB host and its cable to supply power and data. When the host powers up, it queries all of the devices connected to the bus and assigns each an address. This process is called enumeration. Devices are enumerated when they connect to the bus. The host finds out from each device what type of data transfer it wishes to perform:
1. Interrupt—A device like a mouse or a keyboard, which will be sending very little data, would choose the interrupt mode.
2. Bulk—A device like a printer, which receives data in one big packet, uses the bulk transfer mode. A block of data is sent to the printer (in 64-byte segments) and verified to make sure it is correct.
3. Isochronous—a streaming device such as a speaker uses the isochronous mode. Data streams between the device and the host in real-time and there is no error correction. The host can also send commands or query parameters with control packets.
The Universal Serial Bus divides the available bandwidth into frames and the host controls the frames. For USB 1.1 frames contain 1,500 bytes (12,000 bits) and a new frame starts every millisecond. During a one second interval of time 12 megabits of data may be transmitted. For USB 2.0 the data rate is forty times higher and a new frame starts every microsecond. During a one second interval of time 480 megabits of data may be transmitted. USB specifications allow interrupt devices to have a portion of the frames so they are guaranteed the bandwidth they need. Bulk data and control transfers use whatever space is left.
The standard for USB version 2.0 was released in April 2000 and serves as an upgrade for USB 1.1. USB 2.0 (High-speed USB) provides additional bandwidth for multimedia and storage applications. To allow a smooth transition for both consumers and manufacturers, USB 2.0 has full forward and backward compatibility with original USB devices and works with cables and connectors made for earlier versions of USB.
Supporting three speed modes (1.5, 12 and 480 megabits per second), USB 2.0 supports low-bandwidth devices such as keyboards and mice, as well as high-bandwidth devices like high-resolution Webcams, scanners, printers and high-capacity storage systems. The deployment of USB 2.0 has allowed the PC industry to forge ahead with the development of next-generation PC peripherals to complement existing high-performance PCs. The transmission speed of USB 2.0 also facilitates the development of next-generation PCs and applications. In addition to improving functionality and encouraging innovation, USB 2.0 increases the productivity of user applications and allows the user to run multiple PC applications at once or several high-performance peripherals simultaneously.
USB On-the-Go (OTG) is a new USB communication protocol specified in the USB 2.0 specification. USB OTG allows peer-to-peer communications between two USB OTG devices enabling, for example, a digital camera to directly communicate with a printer without the need of a PC as a host. Generally a USB 1.1 device cannot directly communicate with a USB OTG device because of communication protocol differences. As USB OTG is gaining popularity, the demand for USB 1.1 devices to communicate with USB OTG devices has created additional technical challenges.
The OTG supplement to the USB 2.0 specification uses the following defined terms.
Host USB device attaches to a USB cable and acts in the role of initiating all data transmission transactions and provides periodic start-of-frame timing.
USB A-Device supplies power to the Vbus power line. It is host at the start of a transaction session. It will relinquish the role of host to a dual-role B-Device to which it is connected by a USB cable. This can occur only under the rules determined by the host negotiation protocol (HNP).
USB B-Device is always a peripheral at the start of a transaction session. B-devices may be single role (peripheral only) or dual-role (peripheral/host). Typically a B-Device requests a session according to USB 2.0 OTG session request protocol (SRP). If a B-Device is dual-role it may subsequently be granted the role of host from the A-Device under USB 2.0 OTG host negotiation protocol (HNP).
The OTG supplement defines a session request protocol (SRP), which allows a B-device to request the A-device to turn on Vbus and start a session. This protocol allows the A-device, which may be battery powered, to conserve power by turning Vbus off when there is no bus activity while still providing a means for the B-device to initiate bus activity.
Dual-role devices are required to be able to initiate and respond to SRP. Any A-device, including a PC or laptop, is allowed to respond to SRP. Any B-device, including a standard USB peripheral, is allowed to initiate SRP.
The OTG supplement defines two methods used by the B-device to request that the A-device begin a session. They are called data-line pulsing and Vbus pulsing. These two methods comprise the session request protocol (SRP).
The two signaling methods (Vbus pulsing and data-line pulsing) allow maximum latitude in the design of A-devices. An A-device need respond to only one of the two SRP signaling methods. The B-device shall use both methods when initiating SRP to insure that the A-device responds.
The B-device may not attempt to start a new session until it has determined that the A-device has signaled the end of the previous session. The A-device signals the end of a session by allowing Vbus to drop below its session valid threshold (SVT). Since the A-device SVT may be as low as 0.8 volts, the B-device must insure that Vbus is below this level before requesting a new session. The B-device may ensure that Vbus is below the B-device session-end threshold either by direct measurement of Vbus or by timing the discharge.
Additionally, the B-device may switch in a pull-down resistor from Vbus to ground in order to speed the discharge process as long as the pull-down resistor does not cause the B-device to draw more than 8 mA from the Vbus.
A second initial condition for starting a new session is that the B-device must detect that both the D+ and D− data lines have been below the session end detect (SED) threshold for at least 2 mS. This ensures that the A-device has detected a disconnect condition from the B-device.
When the B-Device detects that Vbus has gone below its session end detect (SED) threshold and detects that both D+ and D− have been below SED for at least 2 mS, then any previous session on the A-device is over and a new session may start.
To indicate a request for a new session using the data-line pulsing SRP, the B-device waits until the initial conditions are met and then turns on its data line pull-up resistor (either D+ or D−) for a period of 5 mS to 10 mS. The dual-role B-device is only allowed to initiate SRP at full-speed and thus shall only pull up D+. The duration of such a data line pulse must be sufficient to allow the A-device to reject spurious voltage transients on the data lines. An A-device that is designed to detect the data-line pulsing method of SRP will detect that a data line (either D+ or D−) has gone high and generate an indication that SRP has been detected.
To indicate a request for a new session using the Vbus pulsing method, the B-device waits until the initial conditions are met and then drives Vbus. Vbus is driven for a period that is long enough for a maximum capacitance on Vbus to be charged to 2.1 volts.
There are two scenarios that a B-device could encounter when pulsing Vbus to initiate SRP. In one scenario, the B-device is connected to an A-device that responds to the Vbus pulsing SRP. In this case, the B-device can drive Vbus above the A-device session valid threshold (SVT) in order to wake up the A-device. When driving such an A-device, the B-device shall ensure that Vbus goes above 2.1 volts but does not exceed 5.25 volts.
In the second scenario, the B-device is attached to a standard host. In this case, the B-device shall not drive Vbus above 2.0 volts. This insures that no damage is done to standard hosts that are not designed to withstand a voltage externally applied to Vbus. In order to meet these requirements, the B-device can utilize the fact that the capacitance on a standard host will have well-defined minimum and maximum values. Based on the difference between these two capacitances and a self-imposed current limit, the B-device has a maximum length of time it is allowed to drive Vbus. By driving Vbus for this duration it is possible to guarantee that Vbus will rise above 2.1 volts if attached to a dual-role device, while ensuring that Vbus will not exceed 2.0 volts if attached to a standard USB host.
The B-device Vbus pulsing circuitry must limit the maximum current drawn by the B-Device to 8 mA. One way to ensure this restriction is met is to drive Vbus with a voltage source greater than 3.0 volts and with an output impedance greater than 280 ohms.
The A-device continuously monitors Vbus as long as power is available on the A-device. An A-device that is designed to detect the Vbus pulsing method will detect that Vbus has gone above the A-device session valid threshold (SVT) and generate an indication that SRP has been detected.
When a B-device detects that the voltage on Vbus is greater than the B-Device session valid threshold (SVT), then the B-device shall consider a session to be in progress. After the Vbus voltage crosses this threshold, the B-device shall assert either the D+ or D− data-line within 100 mS.
The maximum time allowed for the B-device to complete all of its SRP initiation activities is 100 mS. The B-device shall first perform data-line pulsing, followed by Vbus pulsing.
Host negotiation protocol (HNP) is used to transfer control of a connection from the default host (A-device) to the default Peripheral (B-device). This is accomplished by the A-device preparing or conditioning the B-device to take control of the bus and then the A-device presenting an opportunity for the B-device to take control.
The B-device is conditioned when the A-device sends a set feature enable (SFE) command. After sending this command, the A-device may suspend the bus to signal the B-device that it may now take control of the bus. If the B-device wants to use the bus at that time, it signals a disconnect to the A-device. If the A-device has enabled the B-device to become host, then the A-device will interpret this disconnect during suspend as a request from the B-device to become host. The A-device will complete the handoff by turning on the pull-up resistor on D+.
When the B-device has finished using the bus, it returns control to the A-device simply by stopping all bus activity and turning on its D+ pull-up resistor. The A-device will detect this lack of activity and turns off its pull-up resistor. When the A-device detects the connection from the B-device, it returns to operation as host.
The following is the normal host negotiation protocol sequence of events:
1. A-device finishes using bus and stops all bus activity, (i.e. suspends the bus).
2. B-device detects that bus is idle for more than 3 mS and begins (HNP) by turning off pull-up on D+. This allows the bus to discharge to the SED state. If the bus was operating in high speed mode, the B-device will first enter the full-speed mode and turn on its D+ pull-up resistor before turning off its pull-up to start the HNP sequence.
3. The A-device detects the SEO on the bus and recognizes this as a request from the B-device to become host. The A-device responds by turning on its D+ pull-up resistor within 3 mS of first detecting the SEO on the bus.
4. After waiting long enough to insure that the D+ line cannot be high due to the residual effect of the B-device pull-up, the B-device sees that the D+ line is high and D− is low. This indicates that the A-device has recognized the HNP request from the B-device. The B-device then becomes host and asserts bus reset to start using the bus. The B-device must assert the bus reset (SEO) within 1.0 mS of the time that the A-device turns on its pull-up.
5. When the B-device completes using the bus, it stops all bus activity. Optionally, the B-device may turn on its D+ pull-up at this time.
6. A-device detects lack of bus activity for more than 3 mS and turns off its D+ pull-up. Alternatively, if the A-device has no further need to communicate with the B-device, the A-device may turn off Vbus and end the session.
7. The B-device turns on its pull-up.
8. After waiting long enough to insure that the D+ line cannot be high due to the residual effect of the A-device pull-up, the A-device sees that the D+ line is high (and D−low) indicating that the B-device is signaling a connect and is ready to respond as a peripheral. The A-device then becomes host and asserts bus reset to start using the bus.